home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / patches / pgs3h21.lha / 3.0h2update / Macros.LHA / InsertSignature.rexx < prev    next >
OS/2 REXX Batch file  |  1995-09-22  |  3KB  |  124 lines

  1. /* $VER: InsertSignature.rexx 1.0a (22.9.95)
  2.    Copyright 1995 Soft-Logik Publishing Corporation
  3.    May not be distributed without Soft-Logik Publishing Corporation's express written permission */
  4.  
  5. OPTIONS RESULTS
  6. ADDRESS 'PAGESTREAM'
  7.  
  8. sMacroName = 'Insert Signature'
  9.  
  10. sSigFile = "PageStream3:Macros/TextClips/SignatureBlock.txt"
  11.  
  12. /* MAIN LOOP */
  13. call OPENLIBS()
  14.  
  15.     if ~exists(sSigFile) then iTemp = getsignature()
  16.     if iTemp ~= 9 then do
  17.         call insertsignature()
  18.         'textcursor right'
  19.     end
  20.  
  21. EXIT
  22.  
  23. INSERTSIGNATURE:
  24. /* INSERT THE SIGNATURE BLOCK */
  25.  
  26.     'inserttext convertquote true convertdash true linehaslf false textcode "" amiga file 'sSigFile' filter Ascii nostatus'
  27.  
  28. RETURN
  29.  
  30. GETSIGNATURE:
  31. /* PRINT SIGNATURE REQUESTER */
  32. rcode=0
  33.  
  34.     /* ALLOCATE REQUESTER */
  35.     allocarexxrequester '"Define Signature Block"' 338 117
  36.         hSigReq=result
  37.  
  38.     /* ADD GADGETS */
  39.     addarexxgadget hSigReq EXIT 12 100 70 label "_Ok"
  40.         hOkGadget=result
  41.     addarexxgadget hSigReq EXIT 256 100 70 label "_Cancel"
  42.         hCancelGadget=result
  43.     sDefault = 'Sincerely,'||d2c(10)||d2c(10)||d2c(10)||d2c(10)||d2c(10)'John Doe'
  44.     addarexxgadget hSigReq MULTILINE 12 10 314 78 string '"'sDefault'"'
  45.         hSigGadget=result
  46.  
  47.     /* SHOW REQUESTER */
  48.     doarexxrequester hSigReq
  49.     if result=hCancelGadget then rcode=9
  50.     else do
  51.         /* GET GADGET STATUS */
  52.         getarexxgadget hSigReq hSigGadget string
  53.             sSigBlock=result
  54.         if length(sSigBlock) <2 then rcode=9
  55.     end
  56.  
  57.     /* FREE REQUESTER */
  58.     freearexxrequester hSigReq
  59.  
  60.     /* CREATE SIGNATUREBLOCK FILE */
  61.     if rcode ~= 9 then do
  62.  
  63.         /* Strip the extra linefeed that pagestream added */
  64.         sSigBlock = left(sSigBlock,length(sSigBlock)-1)
  65.         call open(.ofile, sSigFile, 'W')
  66.             call writeln(.ofile, sSigBlock)
  67.         call close(.ofile)
  68.  
  69.         /* Tell the user how to change the signature block */
  70.         call doalert('You can change your signature block later by editing PageStream3:|Macros/TextClips/SignatureBlock.TXT, or by deleting it and then|running this macro again.')
  71.  
  72.     end
  73.  
  74. RETURN rcode
  75.  
  76. OPENLIBS:
  77.     /* OPEN LIBRARIES */
  78.     IF ~SHOW('L','rexxsupport.library') THEN
  79.         call addlib('rexxsupport.library',0,-30)
  80.     IF ~SHOW('L','softlogik:libs/slarexxsupport.library') THEN
  81.         call addlib("softlogik:libs/slarexxsupport.library", 0, -30)
  82. RETURN
  83.  
  84. DOALERT:
  85. /* GENERAL PURPOSE ALERT REQUESTER */
  86. parse arg sAlertText
  87.  
  88.     iLineCount = 1
  89.     iAlertLength = 1
  90.     iLinePos = pos('|',sAlertText)
  91.  
  92.     /* BREAK ALERT TEXT INTO MULTIPLE LINES. REMEMBER, PAGESTREAM'S MAX IS 10! */
  93.     if iLinePos ~= 0 then do
  94.         do until iLinePos = 0
  95.             sAlertText.iLineCount = left(sAlertText,iLinePos-1)
  96.             iLineLength = length(sAlertText.iLineCount)
  97.             if iLineLength > iAlertLength then iAlertLength = iLineLength
  98.             iLineCount = iLineCount + 1
  99.             sAlertText = right(sAlertText,length(sAlertText)-iLinePos)
  100.             iLinePos = pos('|',sAlertText)
  101.         end
  102.     end
  103.     sAlertText.iLineCount = sAlertText
  104.     iLineLength = length(sAlertText.iLineCount)
  105.     if iLineLength > iAlertLength then iAlertLength = iLineLength
  106.  
  107.     /* Display an alert requester */
  108.     allocarexxrequester '"'sMacroName' Alert"' iAlertLength*8+24 45+iLineCount*10
  109.         hAlertReq=result
  110.     do i = 1 to iLineCount
  111.         addarexxgadget hAlertReq TEXT 8 2+i*10 iAlertLength*8+8 border none string '"'sAlertText.i'"'
  112.     end i
  113.     addarexxgadget hAlertReq EXIT iALertLength*8-58 28+iLineCount*10 70 label "_Exit"
  114.     doarexxrequester hAlertReq
  115.     freearexxrequester hAlertReq
  116.  
  117. RETURN
  118.  
  119. ERROR:
  120. /* TRAP ERRORS */
  121.     call doalert(sError)
  122.  
  123. RETURN 9
  124.